var PredefinedPolygon = Polygon.extend({
    init: function(points, origin){
        this._super(points);
        this._origin = new Point(0,0);
        this.moveTo(origin);
        this._rotationRadius = 0;
    },
    setOrigin: function(origin){
        this.moveTo(origin);
    },
    rotate: function(radius){
        var pivot = (pivot != null) ? pivot : this._origin;
        this._super(radius, pivot);
        this._rotationRadius += radius;
    },
    resetRotation: function(){
        this.rotate(-this._rotationRadius);
    },
    moveTo: function(point){
        if(point != null){
            var x = point.getX() - this._origin.getX();
            var y = point.getY() - this._origin.getY();
            this.translate(x,y);
            this._origin.setX(point.getX());
            this._origin.setY(point.getY());
        }
    },
    scale: function(multiplier){
        this._super(multiplier);
        var oldOrigin = ObjectUtils.clone(this._origin);
        this._origin.setX(this._origin.getX()*multiplier);
        this._origin.setY(this._origin.getY()*multiplier);
        this.moveTo(oldOrigin);
    }
});